package com.siwei.mes.entity.experiment.coarseAggregate;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.util.JsonUtils;
import com.siwei.mes.common.util.NullUtils;
import com.siwei.mes.entity.experiment.Experiment;
import com.siwei.mes.entity.laboratory.coarseAggregate.DataCoarseAggregateKljp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @Description: 粗骨料-筛分析
 * @Version: 1.0
 * @author: YANGKE
 * @date: 2024/02/25 21:29
 */
@Data
@Accessors(chain = true)
public class CoarseAggregateSfx {
    @ApiModelProperty(value = "最大粒径")
    private String zdlj = "";
    @ApiModelProperty(value = "试样重量")
    private String syzl = "";
    @ApiModelProperty(value = "检测日期")
    private String jcrq = "";
    @ApiModelProperty(value = "单项结论")//1
    private String dxjl = "";
    @ApiModelProperty(value = "筛孔公称直径信息")
    private List<CoarseAggregateSfx.SfxInfo> sfxInfo = Collections.singletonList(new CoarseAggregateSfx.SfxInfo());

    @Data
    @Accessors(chain = true)
    @ApiModel("筛孔公称直径信息")
    public static class SfxInfo {
        @ApiModelProperty(value = "筛孔公称直径")
        private String skgjzj = "";
        @ApiModelProperty(value = "分计筛余")//1
        private String fjsy = "";
        @ApiModelProperty(value = "累计筛余")//1
        private String ljsy = "";
        @ApiModelProperty(value = "筛余量")
        private String syl = "";
    }

    /**
     * 字符串转成对象 然后再转成json
     *
     * @param object
     * @return
     */
    private static JSONObject toJsonObject(Object object) {
        CoarseAggregateSfx entity = new CoarseAggregateSfx();
        if (object == null) {
            return JsonUtils.beanToObject(entity);
        }
        if (object instanceof String) {
            entity = JsonUtils.getObject((String) object, CoarseAggregateSfx.class);
        } else if (object instanceof JSONObject) {
            entity = JsonUtils.getObject((JSONObject) object, CoarseAggregateSfx.class);
        }
        return JsonUtils.beanToObject(entity);
    }

    public static String checkIsMust(JSONObject objJson, String name) {
        if (objJson.isEmpty()) {
            return null;
        }
        CoarseAggregateSfx entity = JsonUtils.getObject(objJson, CoarseAggregateSfx.class);
        if (entity == null) {
            return "存在必检项(" + name + ")未检测，请先检测！";
        }
        List<SfxInfo> sfxInfo = entity.getSfxInfo();
        if (sfxInfo == null || sfxInfo.isEmpty()) {
            return "存在必检项(" + name + ")未检测，请先检测！";
        }
        for (SfxInfo info : sfxInfo) {
            if (StringUtils.isBlank(info.getFjsy()) || "null".equals(info.getFjsy())) {
                return "存在必检项(" + name + ")未检测，请先检测！";
            }
            if (StringUtils.isBlank(info.getLjsy()) || "null".equals(info.getLjsy())) {
                return "存在必检项(" + name + ")未检测，请先检测！";
            }
        }
        return null;
    }

    public void setSfxJson(Experiment experiment, CoarseAggregateSfx coarseSfx, DataCoarseAggregateKljp dataCoarseKljp) {
        if (coarseSfx.getSyzl() != null && !coarseSfx.getSyzl().isEmpty()) {
            dataCoarseKljp.setS1(coarseSfx.getSyzl());
        }
        if (coarseSfx.getZdlj() != null && !coarseSfx.getZdlj().isEmpty()) {
            dataCoarseKljp.setS2(coarseSfx.getZdlj());
        }
        String materialsSpecs = experiment.getMaterialsSpecs();
        List<CoarseAggregateSfx.SfxInfo> sfxInfo = coarseSfx.getSfxInfo();
        if (CollectionUtil.isNotEmpty(sfxInfo)) {
            if (materialsSpecs.contains("5～10")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("16.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS3(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS4(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS5(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS6(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS7(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS8(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS9(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS10(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("5.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS11(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS12(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS13(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS14(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS15(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS16(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS17(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS18(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS19(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS20(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS21(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS22(NullUtils.ifNull(sfx.getLjsy()));
                    }
                }
            } else if (materialsSpecs.contains("5～16")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS3(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS4(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS5(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS6(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("16.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS7(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS8(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS9(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS10(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS11(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS12(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS13(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS14(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS15(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS16(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS17(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS18(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS19(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS20(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS21(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS22(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS23(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS24(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS25(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS26(NullUtils.ifNull(sfx.getLjsy()));
                    }
                }
            } else if (materialsSpecs.contains("5～20")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("25.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS3(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS4(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS5(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS6(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS7(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS8(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS9(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS10(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS11(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS12(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS13(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS14(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS15(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS16(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS17(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS18(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS19(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS20(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS21(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS22(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS23(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS24(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS25(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS26(NullUtils.ifNull(sfx.getLjsy()));
                    }
                }
            } else if (materialsSpecs.contains("5～25")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("31.5mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS3(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS4(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS5(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS6(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("25.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS7(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS8(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS9(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS10(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("16.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS11(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS12(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS13(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS14(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS15(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS16(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS17(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS18(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS19(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS20(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS21(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS22(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS23(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS24(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS25(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS26(NullUtils.ifNull(sfx.getLjsy()));
                    }
                }
            } else if (materialsSpecs.contains("5～31.5")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("40.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS3(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS4(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS5(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS6(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("31.5mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS7(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS8(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS9(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS10(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS11(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS12(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS13(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS14(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS15(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS16(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS17(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS18(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS19(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS20(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS21(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS22(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS23(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS24(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS25(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS26(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS27(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS28(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS29(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS30(NullUtils.ifNull(sfx.getLjsy()));
                    }
                }
            } else if (materialsSpecs.contains("5～40")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("50.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS3(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS4(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS5(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS6(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("40.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS7(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS8(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS9(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS10(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS11(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS12(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS13(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS14(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS15(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS16(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS17(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS18(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS19(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS20(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS21(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS22(NullUtils.ifNull(sfx.getLjsy()));
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        dataCoarseKljp.setS23(NullUtils.ifNullReplaceM(sfx.getSkgjzj()));
                        dataCoarseKljp.setS24(NullUtils.ifNull(sfx.getSyl()));
                        dataCoarseKljp.setS25(NullUtils.ifNull(sfx.getFjsy()));
                        dataCoarseKljp.setS26(NullUtils.ifNull(sfx.getLjsy()));
                    }
                }
            } else {
                if (!sfxInfo.isEmpty()) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(11);
                    dataCoarseKljp.setS3(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS4(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS5(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS6(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 2) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(10);
                    dataCoarseKljp.setS7(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS8(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS9(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS10(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 3) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(9);
                    dataCoarseKljp.setS11(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS12(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS13(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS14(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 4) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(8);
                    dataCoarseKljp.setS15(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS16(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS17(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS18(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 5) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(7);
                    dataCoarseKljp.setS19(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS20(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS21(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS22(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 6) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(6);
                    dataCoarseKljp.setS23(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS24(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS25(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS26(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 7) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(5);
                    dataCoarseKljp.setS27(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS28(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS29(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS30(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 8) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(4);
                    dataCoarseKljp.setS31(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS32(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS33(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS34(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 9) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(3);
                    dataCoarseKljp.setS35(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS36(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS37(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS38(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 10) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(2);
                    dataCoarseKljp.setS39(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS40(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS41(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS42(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 11) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(1);
                    dataCoarseKljp.setS43(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS44(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS45(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS46(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
                if (sfxInfo.size() > 12) {
                    CoarseAggregateSfx.SfxInfo sfxInfoOne = sfxInfo.get(0);
                    dataCoarseKljp.setS47(NullUtils.ifNullReplaceM(sfxInfoOne.getSkgjzj()));
                    dataCoarseKljp.setS48(NullUtils.ifNull(sfxInfoOne.getSyl()));
                    dataCoarseKljp.setS49(NullUtils.ifNull(sfxInfoOne.getFjsy()));
                    dataCoarseKljp.setS50(NullUtils.ifNull(sfxInfoOne.getLjsy()));
                }
            }
        }
    }

    public static void setValue(Experiment experiment,CoarseAggregateSfx entity, Map<String, Object> data) {
        if (data.get("Conclusion") != null) {
            entity.setDxjl(data.get("Conclusion").toString());
        }
        if (data.get("S1") != null) {
            entity.setSyzl(data.get("S1").toString());
        }
        if (data.get("S2") != null) {
            entity.setZdlj(data.get("S2").toString());
        }
        String materialsSpecs = experiment.getMaterialsSpecs();
        List<CoarseAggregateSfx.SfxInfo> sfxInfo = entity.getSfxInfo();
        if (CollectionUtil.isNotEmpty(sfxInfo)) {
            if (materialsSpecs.contains("5～10")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("16.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S4") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S4")));
                        }
                        if (data.get("S5") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S5")));
                        }
                        if (data.get("S6") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S6")));
                        }
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S8") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S8")));
                        }
                        if (data.get("S9") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S9")));
                        }
                        if (data.get("S10") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S10")));
                        }
                    }
                    if ("5.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S12") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S12")));
                        }
                        if (data.get("S13") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S13")));
                        }
                        if (data.get("S14") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S14")));
                        }
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S16") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S16")));
                        }
                        if (data.get("S17") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S17")));
                        }
                        if (data.get("S18") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S18")));
                        }
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        if (data.get("S20") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S20")));
                        }
                        if (data.get("S21") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S21")));
                        }
                        if (data.get("S22") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S22")));
                        }
                    }
                }
            } else if (materialsSpecs.contains("5～16")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S4") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S4")));
                        }
                        if (data.get("S5") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S5")));
                        }
                        if (data.get("S6") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S6")));
                        }
                    }
                    if ("16.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S8") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S8")));
                        }
                        if (data.get("S9") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S9")));
                        }
                        if (data.get("S10") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S10")));
                        }
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S12") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S12")));
                        }
                        if (data.get("S13") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S13")));
                        }
                        if (data.get("S14") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S14")));
                        }
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S16") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S16")));
                        }
                        if (data.get("S17") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S17")));
                        }
                        if (data.get("S18") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S18")));
                        }
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S20") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S20")));
                        }
                        if (data.get("S21") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S21")));
                        }
                        if (data.get("S22") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S22")));
                        }
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        if (data.get("S24") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S24")));
                        }
                        if (data.get("S25") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S25")));
                        }
                        if (data.get("S26") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S26")));
                        }
                    }
                }
            } else if (materialsSpecs.contains("5～20")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("25.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S4") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S4")));
                        }
                        if (data.get("S5") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S5")));
                        }
                        if (data.get("S6") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S6")));
                        }
                    }
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S8") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S8")));
                        }
                        if (data.get("S9") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S9")));
                        }
                        if (data.get("S10") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S10")));
                        }
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S12") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S12")));
                        }
                        if (data.get("S13") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S13")));
                        }
                        if (data.get("S14") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S14")));
                        }
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S16") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S16")));
                        }
                        if (data.get("S17") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S17")));
                        }
                        if (data.get("S18") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S18")));
                        }
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S20") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S20")));
                        }
                        if (data.get("S21") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S21")));
                        }
                        if (data.get("S22") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S22")));
                        }
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        if (data.get("S24") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S24")));
                        }
                        if (data.get("S25") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S25")));
                        }
                        if (data.get("S26") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S26")));
                        }
                    }
                }
            } else if (materialsSpecs.contains("5～25")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("31.5mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S4") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S4")));
                        }
                        if (data.get("S5") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S5")));
                        }
                        if (data.get("S6") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S6")));
                        }
                    }
                    if ("25.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S8") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S8")));
                        }
                        if (data.get("S9") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S9")));
                        }
                        if (data.get("S10") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S10")));
                        }
                    }
                    if ("16.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S12") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S12")));
                        }
                        if (data.get("S13") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S13")));
                        }
                        if (data.get("S14") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S14")));
                        }
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S16") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S16")));
                        }
                        if (data.get("S17") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S17")));
                        }
                        if (data.get("S18") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S18")));
                        }
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S20") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S20")));
                        }
                        if (data.get("S21") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S21")));
                        }
                        if (data.get("S22") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S22")));
                        }
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        if (data.get("S24") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S24")));
                        }
                        if (data.get("S25") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S25")));
                        }
                        if (data.get("S26") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S26")));
                        }
                    }
                }
            } else if (materialsSpecs.contains("5～31.5")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("40.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S4") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S4")));
                        }
                        if (data.get("S5") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S5")));
                        }
                        if (data.get("S6") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S6")));
                        }
                    }
                    if ("31.5mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S8") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S8")));
                        }
                        if (data.get("S9") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S9")));
                        }
                        if (data.get("S10") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S10")));
                        }
                    }
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S12") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S12")));
                        }
                        if (data.get("S13") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S13")));
                        }
                        if (data.get("S14") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S14")));
                        }
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S16") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S16")));
                        }
                        if (data.get("S17") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S17")));
                        }
                        if (data.get("S18") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S18")));
                        }
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S20") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S20")));
                        }
                        if (data.get("S21") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S21")));
                        }
                        if (data.get("S22") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S22")));
                        }
                    }
                    if ("2.50mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S24") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S24")));
                        }
                        if (data.get("S25") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S25")));
                        }
                        if (data.get("S26") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S26")));
                        }
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        if (data.get("S28") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S28")));
                        }
                        if (data.get("S29") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S29")));
                        }
                        if (data.get("S30") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S30")));
                        }
                    }
                }
            } else if (materialsSpecs.contains("5～40")) {
                for (CoarseAggregateSfx.SfxInfo sfx : sfxInfo) {
                    if ("50.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S4") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S4")));
                        }
                        if (data.get("S5") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S5")));
                        }
                        if (data.get("S6") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S6")));
                        }
                    }
                    if ("40.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S8") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S8")));
                        }
                        if (data.get("S9") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S9")));
                        }
                        if (data.get("S10") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S10")));
                        }
                    }
                    if ("20.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S12") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S12")));
                        }
                        if (data.get("S13") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S13")));
                        }
                        if (data.get("S14") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S14")));
                        }
                    }
                    if ("10.0mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S16") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S16")));
                        }
                        if (data.get("S17") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S17")));
                        }
                        if (data.get("S18") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S18")));
                        }
                    }
                    if ("5.00mm".equals(sfx.getSkgjzj())) {
                        if (data.get("S20") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S20")));
                        }
                        if (data.get("S21") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S21")));
                        }
                        if (data.get("S22") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S22")));
                        }
                    }
                    if ("筛底".equals(sfx.getSkgjzj())) {
                        if (data.get("S24") != null) {
                            sfx.setSyl(NullUtils.ifNull(data.get("S24")));
                        }
                        if (data.get("S25") != null) {
                            sfx.setFjsy(NullUtils.ifNull(data.get("S25")));
                        }
                        if (data.get("S26") != null) {
                            sfx.setLjsy(NullUtils.ifNull(data.get("S26")));
                        }
                    }
                }
            }
            entity.setSfxInfo(sfxInfo);
        }
    }
}
